<!DOCTYPE html>






  


<html class="theme-next pisces use-motion" lang="zh-CN">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2"/>
<meta name="theme-color" content="#222">












<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />






















<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=6.2.0" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=6.2.0">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=6.2.0">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=6.2.0">


  <link rel="mask-icon" href="/images/logo.svg?v=6.2.0" color="#222">









<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Pisces',
    version: '6.2.0',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: false,
    fastclick: false,
    lazyload: false,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    algolia: {
      applicationID: '884IXKDARU',
      apiKey: '73268cbd2090d14ab01f9fd7b9874762',
      indexName: 'hexo-blogs',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>


  




  <meta name="description" content="参考链接: source.android.com 由于官方提供的参考方法不能使用, 所以我把修改的配置贴了出来 init.hardware.rcon post-fs-data     mkdir /data/media 0770 media_rw media_rw     chown media_rw media_rw /data/media  on init     mkdir /mnt/she">
<meta name="keywords" content="tag">
<meta property="og:type" content="article">
<meta property="og:title" content="Android 4.2.2 Emulate Sdcard">
<meta property="og:url" content="http://linkscue.com/2015/08/19/android4.2.2-emulated-sdcard/index.html">
<meta property="og:site_name" content="Linkscue&#39;s blogs">
<meta property="og:description" content="参考链接: source.android.com 由于官方提供的参考方法不能使用, 所以我把修改的配置贴了出来 init.hardware.rcon post-fs-data     mkdir /data/media 0770 media_rw media_rw     chown media_rw media_rw /data/media  on init     mkdir /mnt/she">
<meta property="og:locale" content="zh-CN">
<meta property="og:updated_time" content="2018-03-12T01:57:15.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Android 4.2.2 Emulate Sdcard">
<meta name="twitter:description" content="参考链接: source.android.com 由于官方提供的参考方法不能使用, 所以我把修改的配置贴了出来 init.hardware.rcon post-fs-data     mkdir /data/media 0770 media_rw media_rw     chown media_rw media_rw /data/media  on init     mkdir /mnt/she">



  <link rel="alternate" href="/atom.xml" title="Linkscue's blogs" type="application/atom+xml" />




  <link rel="canonical" href="http://linkscue.com/2015/08/19/android4.2.2-emulated-sdcard/"/>



<script type="text/javascript" id="page.configurations">
  CONFIG.page = {
    sidebar: "",
  };
</script>

  <title>Android 4.2.2 Emulate Sdcard | Linkscue's blogs</title>
  









  <noscript>
  <style type="text/css">
    .use-motion .motion-element,
    .use-motion .brand,
    .use-motion .menu-item,
    .sidebar-inner,
    .use-motion .post-block,
    .use-motion .pagination,
    .use-motion .comments,
    .use-motion .post-header,
    .use-motion .post-body,
    .use-motion .collection-title { opacity: initial; }

    .use-motion .logo,
    .use-motion .site-title,
    .use-motion .site-subtitle {
      opacity: initial;
      top: initial;
    }

    .use-motion {
      .logo-line-before i { left: initial; }
      .logo-line-after i { right: initial; }
    }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-CN">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Linkscue's blogs</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">清風有情君意愜, 夢徊怡江詩心緣。</p>
      
  </div>

  <div class="site-nav-toggle">
    <button aria-label="切换导航栏">
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>




<nav class="site-nav">
  
    <ul id="menu" class="menu">
      
        
        
        
          
          <li class="menu-item menu-item-home">
    <a href="/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-home"></i> <br />首页</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-about">
    <a href="/about/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-user"></i> <br />关于</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-tags">
    <a href="/tags/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />标签</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-categories">
    <a href="/categories/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-th"></i> <br />分类</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-archives">
    <a href="/archives/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />归档</a>
  </li>

      
      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />搜索</a>
        </li>
      
    </ul>
  

  

  
    <div class="site-search">
      
  
  <div class="algolia-popup popup search-popup">
    <div class="algolia-search">
      <div class="algolia-search-input-icon">
        <i class="fa fa-search"></i>
      </div>
      <div class="algolia-search-input" id="algolia-search-input"></div>
    </div>

    <div class="algolia-results">
      <div id="algolia-stats"></div>
      <div id="algolia-hits"></div>
      <div id="algolia-pagination" class="algolia-pagination"></div>
    </div>

    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
  </div>




    </div>
  
</nav>



  



</div>
    </header>

    


    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          
            

          
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://linkscue.com/2015/08/19/android4.2.2-emulated-sdcard/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="linkscue(scue)">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/assets/images/avatar.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Linkscue's blogs">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">Android 4.2.2 Emulate Sdcard
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">

            
            
            

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              

              
                
              

              <time title="创建时间：2015-08-19 00:00:00" itemprop="dateCreated datePublished" datetime="2015-08-19T00:00:00+08:00">2015-08-19</time>
            

            
              

              
                
                <span class="post-meta-divider">|</span>
                

                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                
                  <span class="post-meta-item-text">更新于</span>
                
                <time title="修改时间：2018-03-12 09:57:15" itemprop="dateModified" datetime="2018-03-12T09:57:15+08:00">2018-03-12</time>
              
            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/技术/" itemprop="url" rel="index"><span itemprop="name">技术</span></a></span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>参考链接: <a href="https://source.android.com/devices/storage/config-example.html" target="_blank" rel="noopener">source.android.com</a></p>
<p>由于官方提供的参考方法不能使用, 所以我把修改的配置贴了出来</p>
<h3 id="init-hardware-rc"><a href="#init-hardware-rc" class="headerlink" title="init.hardware.rc"></a>init.hardware.rc</h3><pre><code>on post-fs-data
    mkdir /data/media 0770 media_rw media_rw
    chown media_rw media_rw /data/media

on init
    mkdir /mnt/shell/emulated 0771 system sdcard_rw
    mkdir /mnt/shell/test 0771 system sdcard_rw
    mkdir /storage/emulated 0775 root root

    export EXTERNAL_STORAGE /storage/emulated/0
    export EMULATED_STORAGE_SOURCE /mnt/shell/emulated
    export EMULATED_STORAGE_TARGET /storage/emulated

    # Support legacy paths
    symlink /storage/emulated/0 /sdcard
    symlink /storage/emulated/0 /mnt/sdcard
    symlink /storage/emulated/0 /storage/sdcard0
    symlink /mnt/shell/emulated/0 /storage/emulated/0

service sdcard /system/bin/sdcard /data/media /mnt/shell/emulated 1023 1023
    disabled

on property:dev.bootcomplete=1
    start sdcard
</code></pre><h3 id="storage-list-xml"><a href="#storage-list-xml" class="headerlink" title="storage_list.xml"></a>storage_list.xml</h3><pre><code>&lt;storage
        android:storageDescription=&quot;@string/storage_internal&quot;
        android:emulated=&quot;true&quot;
        android:mtpReserve=&quot;100&quot; /&gt;
</code></pre><h2 id="实际操作"><a href="#实际操作" class="headerlink" title="实际操作"></a>实际操作</h2><p>由于我希望把 <code>mtd@user</code> 这个分区挂载为 ext4 格式，以减少使用FAT32格式导致文件系统不稳定的引发的问题；</p>
<p>所以，我总体思路是，把 <code>mnt@user</code> 以 ext4 文件系统格式挂载到 <code>/mnt/user</code>；</p>
<p>然后再使用 <code>/system/bin/sdcard</code> 模拟一个SDcard出来至 <code>/mnt/sdcard/emulated</code>；</p>
<p>最后再软链接到 <code>/storage/emulated</code> 和 <code>/mnt/sdcard</code>;</p>
<h3 id="init-rk30board-rc"><a href="#init-rk30board-rc" class="headerlink" title="init.rk30board.rc"></a>init.rk30board.rc</h3><pre><code>on fs
    mkdir /mnt/user 0770 media_rw media_rw
    mount ext4 mtd@user /mnt/user wait noatime nodiratime nosuid nodev noauto_da_alloc

on post-fs
    chown media_rw media_rw /mnt/user

on post-fs-data
    # we will remap this as /mnt/sdcard with the sdcard fuse tool
    mkdir /data/media 0770 media_rw media_rw
    chown media_rw media_rw /data/media

on init

    mkdir /mnt/shell/emulated 0771 system sdcard_rw
    mkdir /mnt/shell/test 0771 system sdcard_rw
    mkdir /storage/emulated 0775 root root

    export EXTERNAL_STORAGE /storage/emulated/0
    export EMULATED_STORAGE_SOURCE /mnt/shell/emulated
    export EMULATED_STORAGE_TARGET /storage/emulated

    # Support legacy paths
    symlink /storage/emulated/0 /sdcard
    symlink /storage/emulated/0 /mnt/sdcard
    symlink /storage/emulated/0 /storage/sdcard0
    symlink /mnt/shell/emulated/0 /storage/emulated/0

    # create virtual SD card at /mnt/sdcard, based on the /data/media directory
    # daemon will drop to user/group system/media_rw after initializing
    # underlying files in /data/media will be created with user and group media_rw (1023)
    service sdcard /system/bin/sdcard /mnt/user /mnt/shell/emulated 1023 1023
       disabled

    # for emulated sdcard
    on property:dev.bootcomplete=1
        start sdcard
</code></pre><h3 id="storage-list-xml-1"><a href="#storage-list-xml-1" class="headerlink" title="storage_list.xml"></a>storage_list.xml</h3><pre><code>&lt;storage
        android:storageDescription=&quot;@string/storage_internal&quot;
        android:emulated=&quot;true&quot;
        android:mtpReserve=&quot;100&quot; /&gt;
</code></pre>
      
    </div>

    

    
    
    

    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/tag/" rel="tag"># tag</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2015/08/05/docker-gitlab/" rel="next" title="使用docker搭建gitlab环境">
                <i class="fa fa-chevron-left"></i> 使用docker搭建gitlab环境
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2015/09/01/android-studio-usage/" rel="prev" title="Android Studio 使用笔记">
                Android Studio 使用笔记 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image"
                src="/assets/images/avatar.png"
                alt="linkscue(scue)" />
            
              <p class="site-author-name" itemprop="name">linkscue(scue)</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          
            <nav class="site-state motion-element">
              
                <div class="site-state-item site-state-posts">
                
                  <a href="/archives/">
                
                    <span class="site-state-item-count">43</span>
                    <span class="site-state-item-name">日志</span>
                  </a>
                </div>
              

              
                
                
                <div class="site-state-item site-state-categories">
                  <a href="/categories/index.html">
                    
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">3</span>
                    <span class="site-state-item-name">分类</span>
                  </a>
                </div>
              

              
                
                
                <div class="site-state-item site-state-tags">
                  <a href="/tags/index.html">
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">29</span>
                    <span class="site-state-item-name">标签</span>
                  </a>
                </div>
              
            </nav>
          

          
            <div class="feed-link motion-element">
              <a href="/atom.xml" rel="alternate">
                <i class="fa fa-rss"></i>
                RSS
              </a>
            </div>
          

          
            <div class="links-of-author motion-element">
              
                <span class="links-of-author-item">
                  <a href="https://github.com/scue" target="_blank" title="GitHub"><i class="fa fa-fw fa-github"></i>GitHub</a>
                  
                </span>
              
                <span class="links-of-author-item">
                  <a href="mailto:scue@vip.qq.com" target="_blank" title="邮箱"><i class="fa fa-fw fa-envelope"></i>邮箱</a>
                  
                </span>
              
                <span class="links-of-author-item">
                  <a href="https://weibo.com/scue" target="_blank" title="微博"><i class="fa fa-fw fa-weibo"></i>微博</a>
                  
                </span>
              
                <span class="links-of-author-item">
                  <a href="https://www.douban.com/people/scue/" target="_blank" title="豆瓣"><i class="fa fa-fw fa-book"></i>豆瓣</a>
                  
                </span>
              
            </div>
          

          
          

          
          

          
            
          
          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#init-hardware-rc"><span class="nav-number">1.</span> <span class="nav-text">init.hardware.rc</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#storage-list-xml"><span class="nav-number">2.</span> <span class="nav-text">storage_list.xml</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#实际操作"><span class="nav-number"></span> <span class="nav-text">实际操作</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#init-rk30board-rc"><span class="nav-number">1.</span> <span class="nav-text">init.rk30board.rc</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#storage-list-xml-1"><span class="nav-number">2.</span> <span class="nav-text">storage_list.xml</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2018</span>
  <span class="with-love" id="animate">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">linkscue(scue)</span>

  

  
</div>




  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动 v3.6.0</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/theme-next/hexo-theme-next">NexT.Pisces</a> v6.2.0</div>




        








        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>


























  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=6.2.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=6.2.0"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=6.2.0"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=6.2.0"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=6.2.0"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=6.2.0"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=6.2.0"></script>



  



	





  





  










  




  
  
  
  <link rel="stylesheet" href="/lib/algolia-instant-search/instantsearch.min.css">

  
  
  <script src="/lib/algolia-instant-search/instantsearch.min.js"></script>
  

  <script src="/js/src/algolia-search.js?v=6.2.0"></script>



  

  

  

  
  

  
  

  


  
  

  

  

  

  

  

</body>
</html>
